<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>第4章 函数与作用域</title>
</head>
<body>
<script>
    function myNoParamFunction() {

    }
    myNoParamFunction();

    function convertToCentigrade(degreesFahrenheit) {
        return 5 / 9 * (degreesFahrenheit - 32);
    }
    var myTemp = convertToCentigrade(212);
    document.write(myTemp + '<br/>');

    function writeUserWelcome(userName) {
        document.write('Welcome to my website ' + userName + '<br/>');
        document.write('Hope you enjoy it!<br/>');
    }
    writeUserWelcome('Paul');
</script>
<script>
    function writeUserWelcome(userName, userAge) {
        document.write('Welcome to my website ' + userName + '<br/>');
        document.write('Hope you enjoy it!<br/>');
        document.write('Your age is ' + userAge + '<br/>');
    }
    writeUserWelcome('Paul', 31);

    var degreesFahrenheit = 12;
    function convertToCentigrade() {
        return 5 / 9 * (degreesFahrenheit - 32);
    }
    convertToCentigrade();
</script>
<script>
    function convertToCentigrade() {
        degreesFahrenheit = 20;
        return 5 / 9 * (degreesFahrenheit - 32);
    }
    convertToCentigrade();
</script>
<script>
    function convertToCentigrade(degreesFahrenheit) {
        return 5 / 9 * (degreesFahrenheit - 32);
    }
    convertToCentigrade();
</script>
<script>
    var degreesCentigrade = 10;
    function convertToCentigrade(degreesFahrenheit) {
        var degreesCentigrade;
        degreesCentigrade = 5 / 9 * (degreesFahrenheit - 32);
        return degreesCentigrade;
    }
    convertToCentigrade(degreesFahrenheit);
    document.write(degreesCentigrade.toString());
</script>
<script>
    function convertToCentigrade(degreesFahrenheit) {
        var degreesCentigrade;
        degreesCentigrade = 5 / 9 * (degreesFahrenheit - 32);
        return degreesCentigrade;
    }
    var myFunction = convertToCentigrade;
    var degreesCentigrade = myFunction(75);
    var degreesCentigrade2 = convertToCentigrade(75);
    document.write(degreesCentigrade);
    document.write(degreesCentigrade2);

    function doSomething(fn) {
        fn('Hello, World');
    }

    doSomething(alert);
</script>
</body>
</html>